function editStares(){
	var stares_container = $('#stares_area');
	stares_container.isotope( 'remove',$('.content') );
	var actions_container = $('#actions_area');
	$.ajax({
			beforeSend: function(){
	            $("#get_more").html('Loading...');
	        },
            type: "POST",
            url: "/stare/edit_stares",
            cache: false,
            success: function(data){
				$('#get_more').html('');
				actions_container.html(data);
            }
        });		
}
function getMoreFeed(url,offset){
	
	$.ajax({
			beforeSend: function(){
	            $("#get_more").html('Loading...');
	        },
			dataType:"json",
            type: "POST",
            url: "portal/get_more_feed",
            data: {
                url: url,
				offset: offset
            },
            cache: false,
            success: function(data){
				
                if ($('#get_more').html()!='') {
                    $('#get_more').html('');
                }
				var container = $('#stares_area');
				var newItems = $(data.msg);
				container.imagesLoaded( function(){
					container.isotope( 'insert', newItems ,initBinding);
					$('#get_more').html(data.next_page);
				});
            }
        });		
}

function changeFeedSource(category){
	var stares_container = $('#stares_area');
	var actions_container = $("#actions_area"); 
	actions_container.html('');
	
	$.ajax({
			beforeSend: function(){
	            $("#get_more").html('Loading...');
	        },
			dataType:"json",
            type: "POST",
            url: "/portal/change_feed_source",
            data: {
                category:category
            },
            cache: false,
            success: function(data){
                $.facebox.close();
                if ($('#get_more').html() != '') {
                    $('#get_more').html('');
                }
                
                stares_container.isotope('remove', $('.content'));
				
                if (data.status) {
					var newItems = $(data.msg);
                    stares_container.imagesLoaded(function(){
                        stares_container.isotope('insert', newItems, initBinding);
                        $('#get_more').html(data.next_page);
                    });
                }
                else {
                    $('#get_more').html(data.msg);
                }
            }
        });		
}

function searchFeed(start_offset,keyword){
	var container = $('#stares_area');
	if(start_offset == 0){
		container.isotope( 'remove',$('.content') );
	}
	var actions_container = $("#actions_area"); 
	actions_container.html('');
	
	$.ajax({
			beforeSend: function(){
	            $("#get_more").html('Loading...');
	        },
			dataType:"json",
            type: "POST",
            url: "/portal/get_blog_results",
            data: {
                start: start_offset,
				q: keyword
            },
            cache: false,
            success: function(data){
				$.facebox.close();
                if ($('#get_more').html()!='') {
                    $('#get_more').html('');
                }
				var newItems = $(data.msg);
				container.imagesLoaded( function(){
					container.isotope( 'insert', newItems ,initBinding);
					$('#get_more').html(data.next_page);
				});
            }
        });		
}

function initBinding() 
{
    $(".content").hover( 
    function() 
    { 
        $(this).addClass("active"); 
		$(this).find(".feed_title").show();
		$(this).find(".feed_share").show();
    }, 
    function() 
    { 
        $(this).removeClass("active");
		$(this).find(".feed_title").hide();
		$(this).find(".feed_share").hide(); 
    }); 
	
	return false;
}
